/*
 * Copyright 2013 NJUT  qixiaobo. All rights reserved.
 */
package com.fujitsu.nanjing.tieba.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fujitsu.nanjing.tieba.base.BaseService;
import com.fujitsu.nanjing.tieba.ibator.CoreArchiveReply;
import com.fujitsu.nanjing.tieba.ibator.CoreArchiveReplyCriteria;
import com.fujitsu.nanjing.tieba.model.ArchiveReply;

/**
 * ArchiveReplyService.java
 * 
 * @author Administrator
 */
@Transactional
@Service
public class ArchiveReplyService
		extends
			BaseService<CoreArchiveReply, CoreArchiveReplyCriteria> {
	@Resource
	private ArchiveReply archiveReply;
	@Override
	public CoreArchiveReply findById(String id) {
		CoreArchiveReplyCriteria example = new CoreArchiveReplyCriteria();
		example.createCriteria().andReplyidEqualTo(Integer.parseInt(id));
		List<CoreArchiveReply> replies = archiveReply
				.selectByExampleWithoutBLOBs(example);
		if (replies != null && replies.size() > 0) {
			return replies.get(0);
		}
		return null;
	}

	@Override
	public CoreArchiveReply insert(CoreArchiveReply t) {
		archiveReply.insertSelective(t);
		return t;
	}

	@Override
	public void update(CoreArchiveReply t) {
		CoreArchiveReplyCriteria example = new CoreArchiveReplyCriteria();
		example.createCriteria().andReplyidEqualTo(t.getReplyid());
		archiveReply.updateByExampleSelective(t, example);

	}

	@Override
	public void delete(CoreArchiveReply t) {
		CoreArchiveReplyCriteria example = new CoreArchiveReplyCriteria();
		example.createCriteria().andReplyidEqualTo(t.getReplyid());
		archiveReply.deleteByExample(example);

	}

}
